home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 March
/
CMCD0305.ISO
/
Software
/
Shareware
/
Utilitare
/
emu
/
Emu8086_Setup_307c.exe
/
{app}
/
Samples
/
bcd_add.asm
< prev
next >
Wrap
Assembly Source File
|
2002-08-02
|
1KB
|
75 lines
; This example shows how to add
; huge unpacked BCD numbers
#make_COM#
ORG 100h
; skip data:
JMP start
; number of digits to
; process:
len EQU 5
; first number is: '79,521':
num1 DB 1,2,5,9,7
; second number is: '82,191':
num2 DB 1,9,1,2,8
; for keeping result,
; result will be '161,712':
sum DB 6 DUP (0)
start: ; entry point.
; digit pointer:
XOR BX, BX
; setup the loop:
MOV CX, len
next_digit:
; add digits:
MOV AL, num1[BX]
ADC AL, num2[BX]
; ASCII adjust:
AAA
; store result:
MOV sum[BX], AL
; point to next digit:
INC BX
LOOP next_digit
; include carry in result (if any):
ADC sum[BX], 0
; print out the result:
MOV CX, len+1
; start printing from
; less significant digit:
MOV BX, len
print_d:
MOV AL, sum[BX]
; convert to ASCII char:
OR AL, 30h
MOV AH, 0Eh
INT 10h
DEC BX
LOOP print_d
RET
END